<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>history</title>
    <link th:href="@{/webjars/bootstrap/3.4.1/css/bootstrap.css}" rel="stylesheet">
</head>
<body>
<div id="videos" th:each="history:${historyList}">
    <div class="col-sm-6 col-md-3">
        <div class="thumbnail">
            <img src="img/uiz7.jpg" th:src="'/img/img'+${history.getCourseId()}+'.jpg'"
                 alt="通用的占位符缩略图">
            <div class="caption" th:id="${history.getCourseId()}">
                <h3><a class="video" href="#" th:href="'/video/video'+${history.getCourseId()}+'.mp4'" th:text="${courseNames.get(history.getCourseId())}">缩略图标签</a></h3>
                <p th:text="${specialties.get(history.getCourseId())}">一些示例文本。一些示例文本。</p>
                <button type="button" class="btn btn-primary deleteHistory" value="deleteHistory">删除历史</button>
                <label th:text="'时间'+${history.getClickTime()}">时间</label>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/webjars/jquery/3.4.1/jquery.js}"></script>
<script>
    $(".video").click(function () {
        var courseId = $(this).parent().parent().attr("id");
        $.ajax({
            type:"POST",
            data:{
                "courseId":courseId
            },
            url:"/clickCourseHref"
            // success:function (result) {
            //
            // }
        })
    });

    $(".deleteHistory").click(function () {
        $.ajax({
            type: "POST",
            url:"/deleteHistory",
            data: {
                "courseId":$(this).parent().attr("id")
            },
            dataType:"json",
            success:function (result) {
                location.reload();
                if(result.success === true) alert("删除成功");
                else alert("删除失败");
            },
            error:function () {
                alert("删除失败");
            }
        })
    })


</script>
</body>
</html>